flowchart TD
    classDef nowrapClass text-align:center,white-space:nowrap;
    classDef callStyle fill:#f2debb,stroke:#333,stroke-width:4px;
    classDef candidateStyle fill:#f2e5ce,stroke:#333,stroke-width:4px;
    classDef stageStyle fill:#c8f0f7,stroke:#333,stroke-width:4px;
    classDef readinessStyle fill:#fff4d6,stroke:#777,stroke-width:1px;

    session0["<tt>Source session for module &lt;main></tt>"]
    class session0 nowrapClass;

    session0 --> call1

    call1["Call 1<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>IllegalStateException#(String(Something is not defined.))</tt></pre>"]
    class call1 nowrapClass;
    class call1 callStyle;

    call1 --> candidate2

    candidate2["Candidate 1: <tt>FirConstructorSymbol java/lang/IllegalStateException.IllegalStateException</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>constructor(p0: String!): {kotlin/IllegalStateException=} IllegalStateException</tt></pre>"]
    class candidate2 nowrapClass;
    class candidate2 candidateStyle;

    candidate2 --> stage3

    stage3["Resolution Stages > CheckArguments"]
    class stage3 nowrapClass;
    class stage3 stageStyle;
    constraint4["<tt>String &lt;: String!</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument String(Something is not defined.)</tt></pre></i>"]
    class constraint4 nowrapClass;
    stage3 ~~~ constraint4

    constraint4 ~~~ candidate5

    candidate5["Candidate 2: <tt>FirConstructorSymbol java/lang/IllegalStateException.IllegalStateException</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>constructor(p0: Throwable!): {kotlin/IllegalStateException=} IllegalStateException</tt></pre>"]
    class candidate5 nowrapClass;
    class candidate5 candidateStyle;

    candidate5 --> stage6

    stage6["Resolution Stages > CheckArguments"]
    class stage6 nowrapClass;
    class stage6 stageStyle;
    constraint8["<tt>String &lt;: Throwable!</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument String(Something is not defined.)</tt></pre></i>"]
    class constraint8 nowrapClass;
    stage6 ~~~ constraint8

    constraint8 ~~~ error7

    error7["<b>NewConstraintError: <tt>kotlin/String &lt;: kotlin/Throwable!</tt><b>"]
    class error7 nowrapClass;

    error7 ~~~ candidate9

    candidate9["Candidate 1: <tt>FirConstructorSymbol java/lang/IllegalStateException.IllegalStateException</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>constructor(p0: String!): {kotlin/IllegalStateException=} IllegalStateException</tt></pre>"]
    class candidate9 nowrapClass;
    class candidate9 candidateStyle;

    candidate9 --> stage10

    stage10["Continue Resolution Stages > CheckLambdaAgainstTypeVariableContradiction"]
    class stage10 nowrapClass;
    class stage10 stageStyle;
    constraint11["<tt>{IllegalStateException=} IllegalStateException &lt;: Throwable</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ExpectedType for some call</tt></pre></i>"]
    class constraint11 nowrapClass;
    stage10 ~~~ constraint11

    constraint11 ~~~ call12

    call12["Call 2<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>parse#(R|&lt;local>/data|)</tt></pre>"]
    class call12 nowrapClass;
    class call12 callStyle;

    call12 --> candidate13

    candidate13["Candidate 1: <tt>FirNamedFunctionSymbol /parse</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>fun &lt;T> parse(data: String): T</tt></pre>"]
    class candidate13 nowrapClass;
    class candidate13 candidateStyle;

    candidate13 --> stage14

    stage14["Resolution Stages > CreateFreshTypeVariableSubstitutorStage"]
    class stage14 nowrapClass;
    class stage14 stageStyle;

    stage14 ~~~ newVariable15

    newVariable15["New <tt>TypeVariable(T)</tt> for <tt>FirNamedFunctionSymbol /parse</tt>s parameter 0"]
    class newVariable15 nowrapClass;

    newVariable15 ~~~ stage16

    stage16["Resolution Stages > CheckArguments"]
    class stage16 nowrapClass;
    class stage16 stageStyle;
    constraint17["<tt>String &lt;: String</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument R|&lt;local>/data|</tt></pre></i>"]
    class constraint17 nowrapClass;
    stage16 ~~~ constraint17

    constraint17 ~~~ stage18

    stage18["Resolution Stages > CheckLambdaAgainstTypeVariableContradiction"]
    class stage18 nowrapClass;
    class stage18 stageStyle;
    constraint19["<tt>TypeVariable(T) &lt;: dynamic</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ExpectedType for some call</tt></pre></i>"]
    class constraint19 nowrapClass;
    stage18 ~~~ constraint19

    constraint19 ~~~ stage20

    stage20["Call Completion"]
    class stage20 nowrapClass;
    class stage20 stageStyle;

    stage20 ~~~ variableReadiness21

    variableReadiness21["Choose <tt>TypeVariable(T)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	false ALLOWED
	false HAS_PROPER_CONSTRAINTS
	false HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	false HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	false HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	false HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	false HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	false HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	false REIFIED
	false HAS_PROPER_NON_NOTHING_NON_ILT_LOWER_CONSTRAINT
	false HAS_PROPER_NON_ILT_CONSTRAINT
	false HAS_PROPER_NON_ILT_EQUALITY_CONSTRAINT
)</tt></pre>"]
    class variableReadiness21 nowrapClass;
    class variableReadiness21 readinessStyle;

    variableReadiness21 ~~~ call22

    call22["Call 3<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>when () {
    ==(this@R|/Test|.R|/Test.something|, Null(null)) ->  {
        throw R|java/lang/IllegalStateException.IllegalStateException|(String(Something is not defined.))
    }
    else ->  {
        R?C|/parse|(R|&lt;local>/data|)
    }
}
</tt></pre>"]
    class call22 nowrapClass;
    class call22 callStyle;

    call22 --> candidate23

    candidate23["Candidate 1: <tt>FirSyntheticFunctionSymbol _synthetic/WHEN_CALL</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>fun &lt;K> WHEN_CALL(vararg branches: K): K
</tt></pre>"]
    class candidate23 nowrapClass;
    class candidate23 candidateStyle;

    candidate23 --> stage24

    stage24["Resolution Stages > CreateFreshTypeVariableSubstitutorStage"]
    class stage24 nowrapClass;
    class stage24 stageStyle;

    stage24 ~~~ newVariable25

    newVariable25["New <tt>TypeVariable(K)</tt> for <tt>FirSyntheticFunctionSymbol _synthetic/WHEN_CALL</tt>s parameter 0"]
    class newVariable25 nowrapClass;

    newVariable25 ~~~ stage26

    stage26["Resolution Stages > CheckArguments"]
    class stage26 nowrapClass;
    class stage26 stageStyle;
    constraint27["<tt>Nothing &lt;: TypeVariable(K)</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument throw R|java/lang/IllegalStateException.IllegalStateException|(String(Something is not defined.))</tt></pre></i>"]
    class constraint27 nowrapClass;
    stage26 ~~~ constraint27
    constraint28["<tt>TypeVariable(T) &lt;: TypeVariable(K)</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument R?C|/parse|(R|&lt;local>/data|)</tt></pre></i>"]
    class constraint28 nowrapClass;
    stage26 ~~~ constraint28

    constraint27 ~~~ stage29
    constraint28 ~~~ stage29

    stage29["Resolution Stages > CheckIncompatibleTypeVariableUpperBounds"]
    class stage29 nowrapClass;
    class stage29 stageStyle;
    constraint30["<tt>TypeVariable(K) == dynamic</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ExpectedType for some call</tt></pre></i>"]
    class constraint30 nowrapClass;
    stage29 ~~~ constraint30
    constraint31["<tt>TypeVariable(T) &lt;: dynamic</tt>"]
    class constraint31 nowrapClass;
    constraint28 --> constraint31
    constraint30 --> constraint31

    constraint31 ~~~ stage32

    stage32["Call Completion"]
    class stage32 nowrapClass;
    class stage32 stageStyle;

    stage32 ~~~ variableReadiness33

    variableReadiness33["Choose <tt>TypeVariable(K)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	 true ALLOWED
	 true HAS_PROPER_CONSTRAINTS
	 true HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	 true HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	 true HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	 true HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	false REIFIED
	false HAS_PROPER_NON_NOTHING_NON_ILT_LOWER_CONSTRAINT
	 true HAS_PROPER_NON_ILT_CONSTRAINT
	 true HAS_PROPER_NON_ILT_EQUALITY_CONSTRAINT
)</tt></pre>"]
    class variableReadiness33 nowrapClass;
    class variableReadiness33 readinessStyle;
    constraint35["<tt>TypeVariable(K) == dynamic</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Fix variable K</tt></pre></i>"]
    class constraint35 nowrapClass;
    variableReadiness33 ~~~ constraint35

    constraint35 ~~~ variableReadiness34

    variableReadiness34["Choose <tt>TypeVariable(T)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	 true ALLOWED
	 true HAS_PROPER_CONSTRAINTS
	 true HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	 true HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	 true HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	 true HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	false REIFIED
	false HAS_PROPER_NON_NOTHING_NON_ILT_LOWER_CONSTRAINT
	 true HAS_PROPER_NON_ILT_CONSTRAINT
	false HAS_PROPER_NON_ILT_EQUALITY_CONSTRAINT
)</tt></pre>"]
    class variableReadiness34 nowrapClass;
    class variableReadiness34 readinessStyle;
    constraint36["<tt>TypeVariable(T) == dynamic</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Fix variable T</tt></pre></i>"]
    class constraint36 nowrapClass;
    variableReadiness34 ~~~ constraint36

    constraint36 ~~~ call37

    call37["Call 4<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>TODO#()</tt></pre>"]
    class call37 nowrapClass;
    class call37 callStyle;

    call37 --> candidate38

    candidate38["Candidate 1: <tt>FirNamedFunctionSymbol kotlin/TODO</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>@InlineOnly() fun TODO(): Nothing
</tt></pre>"]
    class candidate38 nowrapClass;
    class candidate38 candidateStyle;

    candidate38 --> stage39

    stage39["Continue Resolution Stages > CheckLambdaAgainstTypeVariableContradiction"]
    class stage39 nowrapClass;
    class stage39 stageStyle;
    constraint40["<tt>Nothing &lt;: T</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ExpectedType for some call</tt></pre></i>"]
    class constraint40 nowrapClass;
    stage39 ~~~ constraint40

    linkStyle 4 stroke:#990000
    linkStyle 7 stroke:#009999
    linkStyle 11 stroke:#4c9900
    linkStyle 17 stroke:#4c0099
    linkStyle 19 stroke:#994900
    linkStyle 28 stroke:#004f99
    linkStyle 29 stroke:#039900
    linkStyle 31 stroke:#039900
    linkStyle 32 stroke:#950099
    linkStyle 33 stroke:#992400
    linkStyle 36 stroke:#007499
    linkStyle 38 stroke:#279900
    style constraint4 stroke:#990000;
    style constraint8 stroke:#009999;
    style constraint11 stroke:#4c9900;
    style constraint17 stroke:#4c0099;
    style constraint19 stroke:#994900;
    style constraint27 stroke:#004f99;
    style constraint28 stroke:#039900;
    style constraint30 stroke:#950099;
    style constraint31 stroke:#992400;
    style constraint35 stroke:#007499;
    style constraint36 stroke:#279900;